package cn.com.byte1024.utils;

import java.util.Random;

/**
 * 随机生成6位验证码工具类
 * @ProjectName: VoteSystem
 * @ClassName: CodeUtils
 * @Description:随机生成6位验证码工具类
 * @Author: Kwnda
 * @Date: 2021/1/3 22:57
 */
public class CodeUtils {
	private static char[] randRonstant = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

	private static String GenerateRandomNumber(int Length) {
		StringBuilder newRandom = new StringBuilder(10);
		Random rd = new Random();
		for (int i = 0; i < Length; i++) {
			newRandom.append(randRonstant[rd.nextInt(10)]);
		}
		return newRandom.toString();
	}

	public static String GenerateVerificationCode() {
		//返回随机生成的6位验证码
		return GenerateRandomNumber(6);
	}
	
}
